//
//  UserViewController.m
//  Four_Fit
//
//  Created by xalo on 16/7/12.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "UserViewController.h"
#import "EditViewController.h"
#import "InitViewController.h"
#import "StatementViewController.h"
#import "PhotoViewController.h"
#import "CollectViewController.h"

/**
 *  “我的”主界面
 */

@interface UserViewController ()<PassValue>


@property (weak, nonatomic) IBOutlet UIImageView *iconImage;        //头像
@property (weak, nonatomic) IBOutlet UIButton *editBtn;             //编辑按钮
@property (weak, nonatomic) IBOutlet UILabel *IDLable;              //昵称
@property (weak, nonatomic) IBOutlet UILabel *genderLable;          //性别
@property (weak, nonatomic) IBOutlet UILabel *ageLable;             //年龄
@property (weak, nonatomic) IBOutlet UILabel *weightLable;          //体重
@property (weak, nonatomic) IBOutlet UILabel *PurposeLable;         //宣言
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;         //地址
@property (weak, nonatomic) IBOutlet UIButton *exitButton;          //退出登录
@property (weak, nonatomic) IBOutlet UIButton *protocolButton;      //服务协议


@end

@implementation UserViewController



- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"收藏" style:(UIBarButtonItemStylePlain) target:self action:@selector(leftAction:)];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    tap.numberOfTapsRequired = 1;
    [self.iconImage addGestureRecognizer:tap];
    self.iconImage.userInteractionEnabled = YES;
}

- (void)leftAction:(UIBarButtonItem *)sender {
    
    CollectViewController *collectVC = [[CollectViewController alloc]init];
    [self.navigationController pushViewController:collectVC animated:YES];
}
- (IBAction)exitBtn:(id)sender {
    
    InitViewController *initVC = [[InitViewController alloc]init];
    [self.navigationController pushViewController:initVC animated:YES];

}
- (IBAction)protocolBtn:(id)sender {
    
    StatementViewController *statementVC = [[StatementViewController alloc]init];
    [self.navigationController pushViewController:statementVC animated:YES];
}

- (void)tapAction:(UITapGestureRecognizer *)sender {
    
    PhotoViewController *photoVC= [[PhotoViewController alloc]init];
    UINavigationController *photo = [[UINavigationController alloc]initWithRootViewController:photoVC];
    [self.navigationController presentViewController:photo animated:YES completion:nil];
}

- (void)removealertView:(UIAlertController *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

//编辑按钮点击事件
- (IBAction)editBtnAction:(id)sender {
    
    EditViewController *editVC = [[EditViewController alloc]init];
    editVC.IDName = self.IDLable.text;
    editVC.age = self.ageLable.text;
    editVC.gender = self.genderLable.text;
    editVC.purpose = self.PurposeLable.text;
    editVC.weight = self.weightLable.text;
    editVC.address = self.addressLabel.text;
    editVC.delegate = self;
    [self.navigationController pushViewController:editVC animated:YES];
}

- (void)delegatePassValueIDName:(NSString *)IDName
                         Gender:(NSString *)gender
                            Age:(NSString *)age
                         Weight:(NSString *)weight
                        Purpose:(NSString *)purpose
                        Address:(NSString *)address{
    
    self.IDLable.text = IDName;
    self.genderLable.text = gender;
    self.ageLable.text = age;
    self.PurposeLable.text = purpose;
    self.weightLable.text = weight;
    self.addressLabel.text = address;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
